package p270jp.pxv.android.viewholder;

import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.LinearLayoutManager;
import java.util.ArrayList;
import java.util.List;
import p045be.IllustCarouselRecyclerAdapter;
import p045be.NovelCarouselRecyclerAdapter;
import p134ei.AnalyticsScreenName;
import p144f1.C3017s;
import p210hh.PixivAccountManager;
import p216hn.DefaultConstructorMarker;
import p270jp.pxv.android.R;
import p270jp.pxv.android.activity.RankingActivity;
import p270jp.pxv.android.legacy.constant.ContentType;
import p270jp.pxv.android.legacy.model.PixivWork;
import p270jp.pxv.android.widget.SnappyRecyclerView;
import p314lg.ViewHomeRankingCarouselBinding;
import p325m0.MutabilityOwnership;
import p350mp.Timber;
import p370ni.InfoType;
import p370ni.RankingCategory;
import p451qm.CarouselItemDecoration;
import p521th.FlexibleItemAdapterSolidItem;
import p521th.SolidItemViewHolder;
import p677zi.PixivImageLoader;

/* compiled from: HomeRankingListSolidItem.kt */
/* renamed from: jp.pxv.android.viewholder.HomeRankingListSolidItem */
/* loaded from: classes2.dex */
public final class HomeRankingListSolidItem<Work extends PixivWork> extends FlexibleItemAdapterSolidItem {
    public static final int $stable;
    private final ContentType contentType;
    private final PixivImageLoader pixivImageLoader;
    private final List<Work> rankingWorks;
    private final AnalyticsScreenName screenName;

    /* compiled from: HomeRankingListSolidItem.kt */
    /* renamed from: jp.pxv.android.viewholder.HomeRankingListSolidItem$HomeRankingListSolidItemViewHolder */
    /* loaded from: classes2.dex */
    public static final class HomeRankingListSolidItemViewHolder<Work extends PixivWork> extends SolidItemViewHolder {
        public static final Companion Companion = new Companion(null);
        private final ViewHomeRankingCarouselBinding binding;
        private final PixivImageLoader pixivImageLoader;
        private final AnalyticsScreenName screenName;

        /* compiled from: HomeRankingListSolidItem.kt */
        /* renamed from: jp.pxv.android.viewholder.HomeRankingListSolidItem$HomeRankingListSolidItemViewHolder$Companion */
        /* loaded from: classes2.dex */
        public static final class Companion {
            private Companion() {
            }

            public /* synthetic */ Companion(DefaultConstructorMarker eVar) {
                this();
            }

            public final <Work extends PixivWork> HomeRankingListSolidItemViewHolder<Work> createViewHolder(ViewGroup viewGroup, List<? extends Work> list, ContentType contentType, PixivImageLoader aVar, AnalyticsScreenName cVar) {
                MutabilityOwnership.m3745m(viewGroup, "parent");
                MutabilityOwnership.m3745m(list, "rankingWorks");
                MutabilityOwnership.m3745m(contentType, "contentType");
                MutabilityOwnership.m3745m(aVar, "pixivImageLoader");
                MutabilityOwnership.m3745m(cVar, "screenName");
                ViewHomeRankingCarouselBinding k9Var = (ViewHomeRankingCarouselBinding) DataBindingUtil.m11370c(LayoutInflater.from(viewGroup.getContext()), R.layout.view_home_ranking_carousel, viewGroup, false);
                MutabilityOwnership.m3746l(k9Var, "binding");
                return new HomeRankingListSolidItemViewHolder<>(k9Var, aVar, list, contentType, cVar, null);
            }
        }

        /* compiled from: HomeRankingListSolidItem.kt */
        /* renamed from: jp.pxv.android.viewholder.HomeRankingListSolidItem$HomeRankingListSolidItemViewHolder$WhenMappings */
        /* loaded from: classes2.dex */
        public /* synthetic */ class WhenMappings {
            public static final /* synthetic */ int[] $EnumSwitchMapping$0;

            static {
                int[] iArr = new int[ContentType.values().length];
                iArr[ContentType.ILLUST.ordinal()] = 1;
                iArr[ContentType.MANGA.ordinal()] = 2;
                iArr[ContentType.NOVEL.ordinal()] = 3;
                iArr[ContentType.USER.ordinal()] = 4;
                $EnumSwitchMapping$0 = iArr;
            }
        }

        private HomeRankingListSolidItemViewHolder(ViewHomeRankingCarouselBinding k9Var, PixivImageLoader aVar, List<? extends Work> list, ContentType contentType, AnalyticsScreenName cVar) {
            super(k9Var.f2666e);
            this.binding = k9Var;
            this.pixivImageLoader = aVar;
            this.screenName = cVar;
            List<? extends Work> c = C3017s.m6473c(list);
            if (C3017s.m6469g(list.size(), ((ArrayList) c).size())) {
                k9Var.f21844q.m4595d(InfoType.TOO_MANY_MUTE, null);
                k9Var.f21847t.setVisibility(8);
            } else {
                k9Var.f21844q.m4598a();
                k9Var.f21844q.setVisibility(8);
                setupRecyclerView(contentType, c);
            }
            k9Var.f21846s.setText(RankingCategory.f23731f.m3361b(contentType));
            k9Var.f21845r.setOnClickListener(new View$OnClickListenerC4403d(this, contentType));
        }

        public /* synthetic */ HomeRankingListSolidItemViewHolder(ViewHomeRankingCarouselBinding k9Var, PixivImageLoader aVar, List list, ContentType contentType, AnalyticsScreenName cVar, DefaultConstructorMarker eVar) {
            this(k9Var, aVar, list, contentType, cVar);
        }

        /* renamed from: _init_$lambda-0 */
        public static final void m12319_init_$lambda0(HomeRankingListSolidItemViewHolder homeRankingListSolidItemViewHolder, ContentType contentType, View view) {
            MutabilityOwnership.m3745m(homeRankingListSolidItemViewHolder, "this$0");
            MutabilityOwnership.m3745m(contentType, "$contentType");
            homeRankingListSolidItemViewHolder.itemView.getContext().startActivity(RankingActivity.m4760e1(homeRankingListSolidItemViewHolder.itemView.getContext(), contentType));
        }

        /* renamed from: a */
        public static /* synthetic */ void m4432a(HomeRankingListSolidItemViewHolder homeRankingListSolidItemViewHolder, ContentType contentType, View view) {
            m12319_init_$lambda0(homeRankingListSolidItemViewHolder, contentType, view);
        }

        private final void setupRecyclerView(ContentType contentType, List<? extends Work> list) {
            SnappyRecyclerView snappyRecyclerView = this.binding.f21847t;
            Context context = snappyRecyclerView.getContext();
            MutabilityOwnership.m3746l(context, "binding.recyclerView.context");
            Resources resources = context.getResources();
            snappyRecyclerView.m10871g(new CarouselItemDecoration(resources.getDimensionPixelSize(R.dimen.carousel_item_margin_outside), resources.getDimensionPixelSize(R.dimen.carousel_item_margin_inside)));
            int i = WhenMappings.$EnumSwitchMapping$0[contentType.ordinal()];
            if (i == 1 || i == 2) {
                this.binding.f21847t.setAdapter(new IllustCarouselRecyclerAdapter(list, contentType, this.pixivImageLoader, this.screenName));
            } else if (i == 3) {
                this.binding.f21847t.setAdapter(new NovelCarouselRecyclerAdapter(list, this.screenName));
            } else if (i == 4) {
                Timber.f23100a.mo3525d("There is no such thing as user ranking.", new Object[0]);
            }
            SnappyRecyclerView snappyRecyclerView2 = this.binding.f21847t;
            this.itemView.getContext();
            snappyRecyclerView2.setLayoutManager(new LinearLayoutManager(0, false));
        }

        @Override // p521th.SolidItemViewHolder
        public void onBindViewHolder(int i) {
        }
    }

    /* JADX WARN: Multi-variable type inference failed */
    public HomeRankingListSolidItem(List<? extends Work> list, ContentType contentType, PixivImageLoader aVar, AnalyticsScreenName cVar) {
        MutabilityOwnership.m3745m(list, "rankingWorks");
        MutabilityOwnership.m3745m(contentType, "contentType");
        MutabilityOwnership.m3745m(aVar, "pixivImageLoader");
        MutabilityOwnership.m3745m(cVar, "screenName");
        this.rankingWorks = list;
        this.contentType = contentType;
        this.pixivImageLoader = aVar;
        this.screenName = cVar;
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public int getSpanSize() {
        return 2;
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public SolidItemViewHolder onCreateViewHolder(ViewGroup viewGroup) {
        MutabilityOwnership.m3745m(viewGroup, "parent");
        return HomeRankingListSolidItemViewHolder.Companion.createViewHolder(viewGroup, this.rankingWorks, this.contentType, this.pixivImageLoader, this.screenName);
    }

    @Override // p521th.FlexibleItemAdapterSolidItem
    public boolean shouldBeInserted(int i, int i2, int i3, int i4) {
        return i2 == PixivAccountManager.m5511e().f16507m && i3 == 0;
    }
}
